<?php
/**
 * User: hjd-yao
 * Date: 2018/11/26
 * Time: 11:30
 */

namespace Frontend\Providers;


use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class FrontendProvider extends ServiceProvider
{
    protected $namespace = 'Frontend\Http\Controllers';

    public function boot()
    {
        $this->registerRoutes();
        $this->registerViews();
        $this->registerTranslations();
    }

    public function register()
    {

    }

    private function registerRoutes()
    {
        Route::prefix(config('app.frontend_name'))
            ->middleware('web')
            ->namespace($this->namespace)
            ->group(base_path('routes/frontend.php'));

    }

    private function registerViews()
    {
        if(is_mobile()){
            $viewPath = base_path('resources/views/frontend/wap');
        }else{
//            $viewPath = base_path('resources/views/frontend/pc');
            $viewPath = base_path('resources/views/frontend/wap');

        }

        $this->loadViewsFrom($viewPath,'frontend');
    }

    private function registerTranslations()
    {
        $langPath = base_path('resources/lang/frontend');
        $this->loadTranslationsFrom($langPath, 'frontend');
    }
}